package simplescenegraph;


public class LeafNode extends Node {
 
	private SceneObject sceneObject;
	
	protected void updateWorldBound() {
		if (sceneObject != null && sceneObject.getBoundingVolume() != null)
			sceneObject.getBoundingVolume().transformBy(worldTransform);
	}
	
	public void attachSceneObject(SceneObject sceneObject) {
		this.sceneObject = sceneObject;
		sceneObject.setLeafNode(this);
		updated = true;
	}
	
	public SceneObject getAttachedSceneObject() {
		return sceneObject;
	}
	
	public SceneObject detachSceneObject() {
		SceneObject result = sceneObject;
		sceneObject = null;
		result.setLeafNode(null);
		updated = true;
		return result;
	}
	
	public void draw(Renderer renderer) {
		super.draw(renderer);
		sceneObject.draw(renderer);
	}

	public BoundingVolume getWorldBound() {
		return (sceneObject != null) ? sceneObject.getBoundingVolume() : null;		
	}
	 
}
 
